<?php

namespace Yolo\Utils;

use Swoole\Coroutine as Co;

class Async
{
    /**
     * 异步休眠方法，支持长时间休眠，而无需担心超过Swoole\Coroutine::sleep()的限制
     * @param int $seconds
     * @return void
     */
    public static function sleep(int $seconds): void
    {
        if ($seconds <= 3600) {
            Co::sleep($seconds);
            return;
        }

        Co::sleep(3600);
        $seconds -= 3600;
        self::sleep($seconds);
    }
}
